package com.ktjiaoyu.crm.repository;

import com.ktjiaoyu.crm.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @InterfaceName : UserRepository
 * @Description :
 * @Author : Lzz
 * @Date: 2023/11/10 09:35:52
 */
public interface UserRepository extends JpaRepository<User,Long> {


    /**
     * 根据用户名查询用户列表
     * @param userName
     * @return
     */
    List<User> findByUsrName(String userName);

    /**
     * 根据用户名进行模糊查询
     * @param userName
     * @return
     */
    List<User> findByUsrNameLike(String userName);


    @Query("select u from User u where u.usrRoleId=?1")
    List<User> findByUsrRoleId(Long roleId);


    @Query(value = "select * from sys_user where usr_role_id=?1",nativeQuery = true)
    public List<User> findByRoleId(Long roleId);

    /*@Query("select u from User u where u.usrRoleId=:roleId")
    public List<User> findByRoleId(@Param("roleId") Long roleId);*/




}
